
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;


using DotNetNuke.Framework.Providers;


namespace DNNspot.PropertyAgentImport
{
	/// <summary>
	/// Encapsulates the 'Ventrian_PropertyAgent_CustomField' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(CustomField))]	
	[XmlType("CustomField")]
	public partial class CustomField : esCustomField
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new CustomField();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Int32 customFieldID)
		{
			var obj = new CustomField();
			obj.CustomFieldID = customFieldID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Int32 customFieldID, esSqlAccessType sqlAccessType)
		{
			var obj = new CustomField();
			obj.CustomFieldID = customFieldID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("CustomFieldCollection")]
	public partial class CustomFieldCollection : esCustomFieldCollection, IEnumerable<CustomField>
	{
		public CustomField FindByPrimaryKey(System.Int32 customFieldID)
		{
			return this.SingleOrDefault(e => e.CustomFieldID == customFieldID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(CustomField))]
		public class CustomFieldCollectionWCFPacket : esCollectionWCFPacket<CustomFieldCollection>
		{
			public static implicit operator CustomFieldCollection(CustomFieldCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator CustomFieldCollectionWCFPacket(CustomFieldCollection collection)
			{
				return new CustomFieldCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class CustomFieldQuery : esCustomFieldQuery
	{
		public CustomFieldQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "CustomFieldQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(CustomFieldQuery query)
		{
			return CustomFieldQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator CustomFieldQuery(string query)
		{
			return (CustomFieldQuery)CustomFieldQuery.SerializeHelper.FromXml(query, typeof(CustomFieldQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esCustomField : esEntity
	{
		public esCustomField()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Int32 customFieldID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(customFieldID);
			else
				return LoadByPrimaryKeyStoredProcedure(customFieldID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Int32 customFieldID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(customFieldID);
			else
				return LoadByPrimaryKeyStoredProcedure(customFieldID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Int32 customFieldID)
		{
			CustomFieldQuery query = new CustomFieldQuery();
			query.Where(query.CustomFieldID == customFieldID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Int32 customFieldID)
		{
			esParameters parms = new esParameters();
			parms.Add("CustomFieldID", customFieldID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.CustomFieldID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? CustomFieldID
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.CustomFieldID);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.CustomFieldID, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.CustomFieldID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.ModuleID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? ModuleID
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.ModuleID);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.ModuleID, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.ModuleID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.Name
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Name
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.Name);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.Name, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.Name);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? FieldType
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.FieldType);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.FieldType, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldElements
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String FieldElements
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.FieldElements);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.FieldElements, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElements);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.DefaultValue
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String DefaultValue
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.DefaultValue);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.DefaultValue, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.DefaultValue);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.Caption
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String Caption
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.Caption);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.Caption, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.Caption);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.CaptionHelp
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CaptionHelp
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.CaptionHelp);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.CaptionHelp, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.CaptionHelp);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsInManager
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsInManager
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsInManager);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsInManager, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsInManager);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsSortable
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsSortable
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsSortable);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsSortable, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsSortable);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsInListing
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsInListing
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsInListing);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsInListing, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsInListing);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsCaptionHidden
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsCaptionHidden
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsCaptionHidden);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsCaptionHidden, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsCaptionHidden);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsFeatured
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsFeatured
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsFeatured);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsFeatured, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsFeatured);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsPublished
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsPublished
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsPublished);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsPublished, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsPublished);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsHidden
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsHidden
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsHidden);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsHidden, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsHidden);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsSearchable
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsSearchable
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsSearchable);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsSearchable, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsSearchable);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.SortOrder
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? SortOrder
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.SortOrder);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.SortOrder, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.SortOrder);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsRequired
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsRequired
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsRequired);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsRequired, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsRequired);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.ValidationType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? ValidationType
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.ValidationType);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.ValidationType, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.ValidationType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.SearchType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? SearchType
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.SearchType);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.SearchType, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.SearchType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldElementsFrom
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String FieldElementsFrom
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.FieldElementsFrom);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.FieldElementsFrom, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementsFrom);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldElementsTo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String FieldElementsTo
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.FieldElementsTo);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.FieldElementsTo, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementsTo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.Length
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? Length
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.Length);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.Length, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.Length);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IsLockDown
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsLockDown
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IsLockDown);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IsLockDown, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsLockDown);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldElementType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? FieldElementType
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.FieldElementType);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.FieldElementType, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.RegularExpression
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String RegularExpression
		{
			get
			{
				return base.GetSystemString(CustomFieldMetadata.ColumnNames.RegularExpression);
			}
			
			set
			{
				if(base.SetSystemString(CustomFieldMetadata.ColumnNames.RegularExpression, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.RegularExpression);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.IncludeCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IncludeCount
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.IncludeCount);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.IncludeCount, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.IncludeCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.FieldElementDropDown
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? FieldElementDropDown
		{
			get
			{
				return base.GetSystemInt32(CustomFieldMetadata.ColumnNames.FieldElementDropDown);
			}
			
			set
			{
				if(base.SetSystemInt32(CustomFieldMetadata.ColumnNames.FieldElementDropDown, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementDropDown);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.HideZeroCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? HideZeroCount
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.HideZeroCount);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.HideZeroCount, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.HideZeroCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_CustomField.InheritSecurity
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? InheritSecurity
		{
			get
			{
				return base.GetSystemBoolean(CustomFieldMetadata.ColumnNames.InheritSecurity);
			}
			
			set
			{
				if(base.SetSystemBoolean(CustomFieldMetadata.ColumnNames.InheritSecurity, value))
				{
					OnPropertyChanged(CustomFieldMetadata.PropertyNames.InheritSecurity);
				}
			}
		}		
		
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "CustomFieldID": this.str().CustomFieldID = (string)value; break;							
						case "ModuleID": this.str().ModuleID = (string)value; break;							
						case "Name": this.str().Name = (string)value; break;							
						case "FieldType": this.str().FieldType = (string)value; break;							
						case "FieldElements": this.str().FieldElements = (string)value; break;							
						case "DefaultValue": this.str().DefaultValue = (string)value; break;							
						case "Caption": this.str().Caption = (string)value; break;							
						case "CaptionHelp": this.str().CaptionHelp = (string)value; break;							
						case "IsInManager": this.str().IsInManager = (string)value; break;							
						case "IsSortable": this.str().IsSortable = (string)value; break;							
						case "IsInListing": this.str().IsInListing = (string)value; break;							
						case "IsCaptionHidden": this.str().IsCaptionHidden = (string)value; break;							
						case "IsFeatured": this.str().IsFeatured = (string)value; break;							
						case "IsPublished": this.str().IsPublished = (string)value; break;							
						case "IsHidden": this.str().IsHidden = (string)value; break;							
						case "IsSearchable": this.str().IsSearchable = (string)value; break;							
						case "SortOrder": this.str().SortOrder = (string)value; break;							
						case "IsRequired": this.str().IsRequired = (string)value; break;							
						case "ValidationType": this.str().ValidationType = (string)value; break;							
						case "SearchType": this.str().SearchType = (string)value; break;							
						case "FieldElementsFrom": this.str().FieldElementsFrom = (string)value; break;							
						case "FieldElementsTo": this.str().FieldElementsTo = (string)value; break;							
						case "Length": this.str().Length = (string)value; break;							
						case "IsLockDown": this.str().IsLockDown = (string)value; break;							
						case "FieldElementType": this.str().FieldElementType = (string)value; break;							
						case "RegularExpression": this.str().RegularExpression = (string)value; break;							
						case "IncludeCount": this.str().IncludeCount = (string)value; break;							
						case "FieldElementDropDown": this.str().FieldElementDropDown = (string)value; break;							
						case "HideZeroCount": this.str().HideZeroCount = (string)value; break;							
						case "InheritSecurity": this.str().InheritSecurity = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "CustomFieldID":
						
							if (value == null || value is System.Int32)
								this.CustomFieldID = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.CustomFieldID);
							break;
						
						case "ModuleID":
						
							if (value == null || value is System.Int32)
								this.ModuleID = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.ModuleID);
							break;
						
						case "FieldType":
						
							if (value == null || value is System.Int32)
								this.FieldType = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldType);
							break;
						
						case "IsInManager":
						
							if (value == null || value is System.Boolean)
								this.IsInManager = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsInManager);
							break;
						
						case "IsSortable":
						
							if (value == null || value is System.Boolean)
								this.IsSortable = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsSortable);
							break;
						
						case "IsInListing":
						
							if (value == null || value is System.Boolean)
								this.IsInListing = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsInListing);
							break;
						
						case "IsCaptionHidden":
						
							if (value == null || value is System.Boolean)
								this.IsCaptionHidden = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsCaptionHidden);
							break;
						
						case "IsFeatured":
						
							if (value == null || value is System.Boolean)
								this.IsFeatured = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsFeatured);
							break;
						
						case "IsPublished":
						
							if (value == null || value is System.Boolean)
								this.IsPublished = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsPublished);
							break;
						
						case "IsHidden":
						
							if (value == null || value is System.Boolean)
								this.IsHidden = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsHidden);
							break;
						
						case "IsSearchable":
						
							if (value == null || value is System.Boolean)
								this.IsSearchable = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsSearchable);
							break;
						
						case "SortOrder":
						
							if (value == null || value is System.Int32)
								this.SortOrder = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.SortOrder);
							break;
						
						case "IsRequired":
						
							if (value == null || value is System.Boolean)
								this.IsRequired = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsRequired);
							break;
						
						case "ValidationType":
						
							if (value == null || value is System.Int32)
								this.ValidationType = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.ValidationType);
							break;
						
						case "SearchType":
						
							if (value == null || value is System.Int32)
								this.SearchType = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.SearchType);
							break;
						
						case "Length":
						
							if (value == null || value is System.Int32)
								this.Length = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.Length);
							break;
						
						case "IsLockDown":
						
							if (value == null || value is System.Boolean)
								this.IsLockDown = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IsLockDown);
							break;
						
						case "FieldElementType":
						
							if (value == null || value is System.Int32)
								this.FieldElementType = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementType);
							break;
						
						case "IncludeCount":
						
							if (value == null || value is System.Boolean)
								this.IncludeCount = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.IncludeCount);
							break;
						
						case "FieldElementDropDown":
						
							if (value == null || value is System.Int32)
								this.FieldElementDropDown = (System.Int32?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.FieldElementDropDown);
							break;
						
						case "HideZeroCount":
						
							if (value == null || value is System.Boolean)
								this.HideZeroCount = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.HideZeroCount);
							break;
						
						case "InheritSecurity":
						
							if (value == null || value is System.Boolean)
								this.InheritSecurity = (System.Boolean?)value;
								OnPropertyChanged(CustomFieldMetadata.PropertyNames.InheritSecurity);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esCustomField entity)
			{
				this.entity = entity;
			}
			
	
			public System.String CustomFieldID
			{
				get
				{
					System.Int32? data = entity.CustomFieldID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CustomFieldID = null;
					else entity.CustomFieldID = Convert.ToInt32(value);
				}
			}
				
			public System.String ModuleID
			{
				get
				{
					System.Int32? data = entity.ModuleID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ModuleID = null;
					else entity.ModuleID = Convert.ToInt32(value);
				}
			}
				
			public System.String Name
			{
				get
				{
					System.String data = entity.Name;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Name = null;
					else entity.Name = Convert.ToString(value);
				}
			}
				
			public System.String FieldType
			{
				get
				{
					System.Int32? data = entity.FieldType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldType = null;
					else entity.FieldType = Convert.ToInt32(value);
				}
			}
				
			public System.String FieldElements
			{
				get
				{
					System.String data = entity.FieldElements;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldElements = null;
					else entity.FieldElements = Convert.ToString(value);
				}
			}
				
			public System.String DefaultValue
			{
				get
				{
					System.String data = entity.DefaultValue;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DefaultValue = null;
					else entity.DefaultValue = Convert.ToString(value);
				}
			}
				
			public System.String Caption
			{
				get
				{
					System.String data = entity.Caption;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Caption = null;
					else entity.Caption = Convert.ToString(value);
				}
			}
				
			public System.String CaptionHelp
			{
				get
				{
					System.String data = entity.CaptionHelp;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CaptionHelp = null;
					else entity.CaptionHelp = Convert.ToString(value);
				}
			}
				
			public System.String IsInManager
			{
				get
				{
					System.Boolean? data = entity.IsInManager;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsInManager = null;
					else entity.IsInManager = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsSortable
			{
				get
				{
					System.Boolean? data = entity.IsSortable;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsSortable = null;
					else entity.IsSortable = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsInListing
			{
				get
				{
					System.Boolean? data = entity.IsInListing;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsInListing = null;
					else entity.IsInListing = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsCaptionHidden
			{
				get
				{
					System.Boolean? data = entity.IsCaptionHidden;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsCaptionHidden = null;
					else entity.IsCaptionHidden = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsFeatured
			{
				get
				{
					System.Boolean? data = entity.IsFeatured;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsFeatured = null;
					else entity.IsFeatured = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsPublished
			{
				get
				{
					System.Boolean? data = entity.IsPublished;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsPublished = null;
					else entity.IsPublished = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsHidden
			{
				get
				{
					System.Boolean? data = entity.IsHidden;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsHidden = null;
					else entity.IsHidden = Convert.ToBoolean(value);
				}
			}
				
			public System.String IsSearchable
			{
				get
				{
					System.Boolean? data = entity.IsSearchable;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsSearchable = null;
					else entity.IsSearchable = Convert.ToBoolean(value);
				}
			}
				
			public System.String SortOrder
			{
				get
				{
					System.Int32? data = entity.SortOrder;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.SortOrder = null;
					else entity.SortOrder = Convert.ToInt32(value);
				}
			}
				
			public System.String IsRequired
			{
				get
				{
					System.Boolean? data = entity.IsRequired;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsRequired = null;
					else entity.IsRequired = Convert.ToBoolean(value);
				}
			}
				
			public System.String ValidationType
			{
				get
				{
					System.Int32? data = entity.ValidationType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ValidationType = null;
					else entity.ValidationType = Convert.ToInt32(value);
				}
			}
				
			public System.String SearchType
			{
				get
				{
					System.Int32? data = entity.SearchType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.SearchType = null;
					else entity.SearchType = Convert.ToInt32(value);
				}
			}
				
			public System.String FieldElementsFrom
			{
				get
				{
					System.String data = entity.FieldElementsFrom;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldElementsFrom = null;
					else entity.FieldElementsFrom = Convert.ToString(value);
				}
			}
				
			public System.String FieldElementsTo
			{
				get
				{
					System.String data = entity.FieldElementsTo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldElementsTo = null;
					else entity.FieldElementsTo = Convert.ToString(value);
				}
			}
				
			public System.String Length
			{
				get
				{
					System.Int32? data = entity.Length;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Length = null;
					else entity.Length = Convert.ToInt32(value);
				}
			}
				
			public System.String IsLockDown
			{
				get
				{
					System.Boolean? data = entity.IsLockDown;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsLockDown = null;
					else entity.IsLockDown = Convert.ToBoolean(value);
				}
			}
				
			public System.String FieldElementType
			{
				get
				{
					System.Int32? data = entity.FieldElementType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldElementType = null;
					else entity.FieldElementType = Convert.ToInt32(value);
				}
			}
				
			public System.String RegularExpression
			{
				get
				{
					System.String data = entity.RegularExpression;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.RegularExpression = null;
					else entity.RegularExpression = Convert.ToString(value);
				}
			}
				
			public System.String IncludeCount
			{
				get
				{
					System.Boolean? data = entity.IncludeCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IncludeCount = null;
					else entity.IncludeCount = Convert.ToBoolean(value);
				}
			}
				
			public System.String FieldElementDropDown
			{
				get
				{
					System.Int32? data = entity.FieldElementDropDown;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FieldElementDropDown = null;
					else entity.FieldElementDropDown = Convert.ToInt32(value);
				}
			}
				
			public System.String HideZeroCount
			{
				get
				{
					System.Boolean? data = entity.HideZeroCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.HideZeroCount = null;
					else entity.HideZeroCount = Convert.ToBoolean(value);
				}
			}
				
			public System.String InheritSecurity
			{
				get
				{
					System.Boolean? data = entity.InheritSecurity;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.InheritSecurity = null;
					else entity.InheritSecurity = Convert.ToBoolean(value);
				}
			}
			

			private esCustomField entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return CustomFieldMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public CustomFieldQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new CustomFieldQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(CustomFieldQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(CustomFieldQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private CustomFieldQuery query;		
	}



	[Serializable]
	abstract public partial class esCustomFieldCollection : esEntityCollection<CustomField>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return CustomFieldMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "CustomFieldCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public CustomFieldQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new CustomFieldQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(CustomFieldQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new CustomFieldQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(CustomFieldQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((CustomFieldQuery)query);
		}

		#endregion
		
		private CustomFieldQuery query;
	}



	[Serializable]
	abstract public partial class esCustomFieldQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return CustomFieldMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "CustomFieldID": return this.CustomFieldID;
				case "ModuleID": return this.ModuleID;
				case "Name": return this.Name;
				case "FieldType": return this.FieldType;
				case "FieldElements": return this.FieldElements;
				case "DefaultValue": return this.DefaultValue;
				case "Caption": return this.Caption;
				case "CaptionHelp": return this.CaptionHelp;
				case "IsInManager": return this.IsInManager;
				case "IsSortable": return this.IsSortable;
				case "IsInListing": return this.IsInListing;
				case "IsCaptionHidden": return this.IsCaptionHidden;
				case "IsFeatured": return this.IsFeatured;
				case "IsPublished": return this.IsPublished;
				case "IsHidden": return this.IsHidden;
				case "IsSearchable": return this.IsSearchable;
				case "SortOrder": return this.SortOrder;
				case "IsRequired": return this.IsRequired;
				case "ValidationType": return this.ValidationType;
				case "SearchType": return this.SearchType;
				case "FieldElementsFrom": return this.FieldElementsFrom;
				case "FieldElementsTo": return this.FieldElementsTo;
				case "Length": return this.Length;
				case "IsLockDown": return this.IsLockDown;
				case "FieldElementType": return this.FieldElementType;
				case "RegularExpression": return this.RegularExpression;
				case "IncludeCount": return this.IncludeCount;
				case "FieldElementDropDown": return this.FieldElementDropDown;
				case "HideZeroCount": return this.HideZeroCount;
				case "InheritSecurity": return this.InheritSecurity;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem CustomFieldID
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.CustomFieldID, esSystemType.Int32); }
		} 
		
		public esQueryItem ModuleID
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.ModuleID, esSystemType.Int32); }
		} 
		
		public esQueryItem Name
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.Name, esSystemType.String); }
		} 
		
		public esQueryItem FieldType
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldType, esSystemType.Int32); }
		} 
		
		public esQueryItem FieldElements
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldElements, esSystemType.String); }
		} 
		
		public esQueryItem DefaultValue
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.DefaultValue, esSystemType.String); }
		} 
		
		public esQueryItem Caption
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.Caption, esSystemType.String); }
		} 
		
		public esQueryItem CaptionHelp
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.CaptionHelp, esSystemType.String); }
		} 
		
		public esQueryItem IsInManager
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsInManager, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsSortable
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsSortable, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsInListing
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsInListing, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsCaptionHidden
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsCaptionHidden, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsFeatured
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsFeatured, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsPublished
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsPublished, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsHidden
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsHidden, esSystemType.Boolean); }
		} 
		
		public esQueryItem IsSearchable
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsSearchable, esSystemType.Boolean); }
		} 
		
		public esQueryItem SortOrder
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.SortOrder, esSystemType.Int32); }
		} 
		
		public esQueryItem IsRequired
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsRequired, esSystemType.Boolean); }
		} 
		
		public esQueryItem ValidationType
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.ValidationType, esSystemType.Int32); }
		} 
		
		public esQueryItem SearchType
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.SearchType, esSystemType.Int32); }
		} 
		
		public esQueryItem FieldElementsFrom
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldElementsFrom, esSystemType.String); }
		} 
		
		public esQueryItem FieldElementsTo
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldElementsTo, esSystemType.String); }
		} 
		
		public esQueryItem Length
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.Length, esSystemType.Int32); }
		} 
		
		public esQueryItem IsLockDown
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IsLockDown, esSystemType.Boolean); }
		} 
		
		public esQueryItem FieldElementType
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldElementType, esSystemType.Int32); }
		} 
		
		public esQueryItem RegularExpression
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.RegularExpression, esSystemType.String); }
		} 
		
		public esQueryItem IncludeCount
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.IncludeCount, esSystemType.Boolean); }
		} 
		
		public esQueryItem FieldElementDropDown
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.FieldElementDropDown, esSystemType.Int32); }
		} 
		
		public esQueryItem HideZeroCount
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.HideZeroCount, esSystemType.Boolean); }
		} 
		
		public esQueryItem InheritSecurity
		{
			get { return new esQueryItem(this, CustomFieldMetadata.ColumnNames.InheritSecurity, esSystemType.Boolean); }
		} 
		
		#endregion
		
	}


	
	public partial class CustomField : esCustomField
	{

		#region PropertyValueCollectionByCustomFieldID - Zero To Many
		
		static public esPrefetchMap Prefetch_PropertyValueCollectionByCustomFieldID
		{
			get
			{
				esPrefetchMap map = new esPrefetchMap();
				map.PrefetchDelegate = DNNspot.PropertyAgentImport.CustomField.PropertyValueCollectionByCustomFieldID_Delegate;
				map.PropertyName = "PropertyValueCollectionByCustomFieldID";
				map.MyColumnName = "CustomFieldID";
				map.ParentColumnName = "CustomFieldID";
				map.IsMultiPartKey = false;
				return map;
			}
		}		
		
		static private void PropertyValueCollectionByCustomFieldID_Delegate(esPrefetchParameters data)
		{
			CustomFieldQuery parent = new CustomFieldQuery(data.NextAlias());

			PropertyValueQuery me = data.You != null ? data.You as PropertyValueQuery : new PropertyValueQuery(data.NextAlias());

			if (data.Root == null)
			{
				data.Root = me;
			}
			
			data.Root.InnerJoin(parent).On(parent.CustomFieldID == me.CustomFieldID);

			data.You = parent;
		}			
		
		/// <summary>
		/// Zero to Many
		/// Foreign Key Name - FK_Ventrian_EstateAgent_PropertyValue_Ventrian_EstateAgent_CustomField
		/// </summary>

		[XmlIgnore]
		public PropertyValueCollection PropertyValueCollectionByCustomFieldID
		{
			get
			{
				if(this._PropertyValueCollectionByCustomFieldID == null)
				{
					this._PropertyValueCollectionByCustomFieldID = new PropertyValueCollection();
					this._PropertyValueCollectionByCustomFieldID.es.Connection.Name = this.es.Connection.Name;
					this.SetPostSave("PropertyValueCollectionByCustomFieldID", this._PropertyValueCollectionByCustomFieldID);
				
					if (this.CustomFieldID != null)
					{
						if (!this.es.IsLazyLoadDisabled)
						{
							this._PropertyValueCollectionByCustomFieldID.Query.Where(this._PropertyValueCollectionByCustomFieldID.Query.CustomFieldID == this.CustomFieldID);
							this._PropertyValueCollectionByCustomFieldID.Query.Load();
						}

						// Auto-hookup Foreign Keys
						this._PropertyValueCollectionByCustomFieldID.fks.Add(PropertyValueMetadata.ColumnNames.CustomFieldID, this.CustomFieldID);
					}
				}

				return this._PropertyValueCollectionByCustomFieldID;
			}
			
			set 
			{ 
				if (value != null) throw new Exception("'value' Must be null"); 
			 
				if (this._PropertyValueCollectionByCustomFieldID != null) 
				{ 
					this.RemovePostSave("PropertyValueCollectionByCustomFieldID"); 
					this._PropertyValueCollectionByCustomFieldID = null;
					
				} 
			} 			
		}
			
		
		private PropertyValueCollection _PropertyValueCollectionByCustomFieldID;
		#endregion

		
		protected override esEntityCollectionBase CreateCollectionForPrefetch(string name)
		{
			esEntityCollectionBase coll = null;

			switch (name)
			{
				case "PropertyValueCollectionByCustomFieldID":
					coll = this.PropertyValueCollectionByCustomFieldID;
					break;	
			}

			return coll;
		}		
		/// <summary>
		/// Used internally by the entity's hierarchical properties.
		/// </summary>
		protected override List<esPropertyDescriptor> GetHierarchicalProperties()
		{
			List<esPropertyDescriptor> props = new List<esPropertyDescriptor>();
			
			props.Add(new esPropertyDescriptor(this, "PropertyValueCollectionByCustomFieldID", typeof(PropertyValueCollection), new PropertyValue()));
		
			return props;
		}
		
		/// <summary>
		/// Called by ApplyPostSaveKeys 
		/// </summary>
		/// <param name="coll">The collection to enumerate over</param>
		/// <param name="key">"The column name</param>
		/// <param name="value">The column value</param>
		private void Apply(esEntityCollectionBase coll, string key, object value)
		{
			foreach (esEntity obj in coll)
			{
				if (obj.es.IsAdded)
				{
					obj.SetProperty(key, value);
				}
			}
		}
		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PostSave.
		/// </summary>
		protected override void ApplyPostSaveKeys()
		{
			if(this._PropertyValueCollectionByCustomFieldID != null)
			{
				Apply(this._PropertyValueCollectionByCustomFieldID, "CustomFieldID", this.CustomFieldID);
			}
		}
		
	}
	



	[Serializable]
	public partial class CustomFieldMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected CustomFieldMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.CustomFieldID, 0, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.CustomFieldID;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.ModuleID, 1, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.ModuleID;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.Name, 2, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.Name;
			c.CharacterMaxLength = 255;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldType, 3, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldType;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldElements, 4, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldElements;
			c.CharacterMaxLength = 1073741823;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.DefaultValue, 5, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.DefaultValue;
			c.CharacterMaxLength = 255;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.Caption, 6, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.Caption;
			c.CharacterMaxLength = 255;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.CaptionHelp, 7, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.CaptionHelp;
			c.CharacterMaxLength = 255;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsInManager, 8, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsInManager;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsSortable, 9, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsSortable;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsInListing, 10, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsInListing;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsCaptionHidden, 11, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsCaptionHidden;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsFeatured, 12, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsFeatured;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsPublished, 13, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsPublished;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsHidden, 14, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsHidden;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsSearchable, 15, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsSearchable;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.SortOrder, 16, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.SortOrder;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsRequired, 17, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsRequired;
			c.HasDefault = true;
			c.Default = @"((1))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.ValidationType, 18, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.ValidationType;
			c.NumericPrecision = 10;
			c.HasDefault = true;
			c.Default = @"((0))";
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.SearchType, 19, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.SearchType;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldElementsFrom, 20, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldElementsFrom;
			c.CharacterMaxLength = 4000;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldElementsTo, 21, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldElementsTo;
			c.CharacterMaxLength = 4000;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.Length, 22, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.Length;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IsLockDown, 23, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IsLockDown;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldElementType, 24, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldElementType;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.RegularExpression, 25, typeof(System.String), esSystemType.String);
			c.PropertyName = CustomFieldMetadata.PropertyNames.RegularExpression;
			c.CharacterMaxLength = 500;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.IncludeCount, 26, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.IncludeCount;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.FieldElementDropDown, 27, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = CustomFieldMetadata.PropertyNames.FieldElementDropDown;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.HideZeroCount, 28, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.HideZeroCount;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(CustomFieldMetadata.ColumnNames.InheritSecurity, 29, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = CustomFieldMetadata.PropertyNames.InheritSecurity;
			c.HasDefault = true;
			c.Default = @"((1))";
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public CustomFieldMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string CustomFieldID = "CustomFieldID";
			 public const string ModuleID = "ModuleID";
			 public const string Name = "Name";
			 public const string FieldType = "FieldType";
			 public const string FieldElements = "FieldElements";
			 public const string DefaultValue = "DefaultValue";
			 public const string Caption = "Caption";
			 public const string CaptionHelp = "CaptionHelp";
			 public const string IsInManager = "IsInManager";
			 public const string IsSortable = "IsSortable";
			 public const string IsInListing = "IsInListing";
			 public const string IsCaptionHidden = "IsCaptionHidden";
			 public const string IsFeatured = "IsFeatured";
			 public const string IsPublished = "IsPublished";
			 public const string IsHidden = "IsHidden";
			 public const string IsSearchable = "IsSearchable";
			 public const string SortOrder = "SortOrder";
			 public const string IsRequired = "IsRequired";
			 public const string ValidationType = "ValidationType";
			 public const string SearchType = "SearchType";
			 public const string FieldElementsFrom = "FieldElementsFrom";
			 public const string FieldElementsTo = "FieldElementsTo";
			 public const string Length = "Length";
			 public const string IsLockDown = "IsLockDown";
			 public const string FieldElementType = "FieldElementType";
			 public const string RegularExpression = "RegularExpression";
			 public const string IncludeCount = "IncludeCount";
			 public const string FieldElementDropDown = "FieldElementDropDown";
			 public const string HideZeroCount = "HideZeroCount";
			 public const string InheritSecurity = "InheritSecurity";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string CustomFieldID = "CustomFieldID";
			 public const string ModuleID = "ModuleID";
			 public const string Name = "Name";
			 public const string FieldType = "FieldType";
			 public const string FieldElements = "FieldElements";
			 public const string DefaultValue = "DefaultValue";
			 public const string Caption = "Caption";
			 public const string CaptionHelp = "CaptionHelp";
			 public const string IsInManager = "IsInManager";
			 public const string IsSortable = "IsSortable";
			 public const string IsInListing = "IsInListing";
			 public const string IsCaptionHidden = "IsCaptionHidden";
			 public const string IsFeatured = "IsFeatured";
			 public const string IsPublished = "IsPublished";
			 public const string IsHidden = "IsHidden";
			 public const string IsSearchable = "IsSearchable";
			 public const string SortOrder = "SortOrder";
			 public const string IsRequired = "IsRequired";
			 public const string ValidationType = "ValidationType";
			 public const string SearchType = "SearchType";
			 public const string FieldElementsFrom = "FieldElementsFrom";
			 public const string FieldElementsTo = "FieldElementsTo";
			 public const string Length = "Length";
			 public const string IsLockDown = "IsLockDown";
			 public const string FieldElementType = "FieldElementType";
			 public const string RegularExpression = "RegularExpression";
			 public const string IncludeCount = "IncludeCount";
			 public const string FieldElementDropDown = "FieldElementDropDown";
			 public const string HideZeroCount = "HideZeroCount";
			 public const string InheritSecurity = "InheritSecurity";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(CustomFieldMetadata))
			{
				if(CustomFieldMetadata.mapDelegates == null)
				{
					CustomFieldMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (CustomFieldMetadata.meta == null)
				{
					CustomFieldMetadata.meta = new CustomFieldMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("CustomFieldID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("ModuleID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("Name", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("FieldType", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("FieldElements", new esTypeMap("ntext", "System.String"));
				meta.AddTypeMap("DefaultValue", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("Caption", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("CaptionHelp", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("IsInManager", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsSortable", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsInListing", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsCaptionHidden", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsFeatured", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsPublished", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsHidden", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("IsSearchable", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("SortOrder", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("IsRequired", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("ValidationType", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("SearchType", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("FieldElementsFrom", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("FieldElementsTo", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("Length", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("IsLockDown", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("FieldElementType", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("RegularExpression", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("IncludeCount", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("FieldElementDropDown", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("HideZeroCount", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("InheritSecurity", new esTypeMap("bit", "System.Boolean"));			
				
				
				
				ProviderConfiguration providerConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
				Provider provider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];

				string objectQualifier = provider.Attributes["objectQualifier"];

				if ((objectQualifier != string.Empty) && (objectQualifier.EndsWith("_") == false))
				{
					objectQualifier += "_";
				}

				if (objectQualifier != string.Empty)
				{
					meta.Source = objectQualifier + "Ventrian_PropertyAgent_CustomField";
					meta.Destination = objectQualifier + "Ventrian_PropertyAgent_CustomField";
					
					meta.spInsert = objectQualifier + "proc_Ventrian_PropertyAgent_CustomFieldInsert";				
					meta.spUpdate = objectQualifier + "proc_Ventrian_PropertyAgent_CustomFieldUpdate";		
					meta.spDelete = objectQualifier + "proc_Ventrian_PropertyAgent_CustomFieldDelete";
					meta.spLoadAll = objectQualifier + "proc_Ventrian_PropertyAgent_CustomFieldLoadAll";
					meta.spLoadByPrimaryKey = objectQualifier + "proc_Ventrian_PropertyAgent_CustomFieldLoadByPrimaryKey";
				}
				else
				{
					meta.Source = "Ventrian_PropertyAgent_CustomField";
					meta.Destination = "Ventrian_PropertyAgent_CustomField";
									
					meta.spInsert = "proc_Ventrian_PropertyAgent_CustomFieldInsert";				
					meta.spUpdate = "proc_Ventrian_PropertyAgent_CustomFieldUpdate";		
					meta.spDelete = "proc_Ventrian_PropertyAgent_CustomFieldDelete";
					meta.spLoadAll = "proc_Ventrian_PropertyAgent_CustomFieldLoadAll";
					meta.spLoadByPrimaryKey = "proc_Ventrian_PropertyAgent_CustomFieldLoadByPrimaryKey";
				}
				
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private CustomFieldMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
